package com.xiaofeng.springboot.domain.entity;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import tk.mybatis.mapper.annotation.NameStyle;

/**
 * 用户实体类
 * @author chenzf
 *
 */
@Entity
@Table(name = "MD_USER")
@NameStyle
public class UserEntity extends BaseEntity {

	private static final long serialVersionUID = -3878004279547932165L;
	/** 普通用户 */
	public static final int ROLEID_USER = 0;
	/**会员*/
	public static final int ROLEID_VIP = 1;
	/** 管理员 */
	public static final int ROLEID_ADMIN = 2;

	/** 可用 */
	public static final int STATUS_ENABLE = 0;
	/** 禁用 */
	public static final int STATUS_DISABLE = 1;
	private String loginName; //登录账号
	private String username; //用户名
	private String mobile; //手机号码
	private String password; //密码
	private String mail; //邮箱
	private String qq; //QQ
	private Integer roleId; //角色等级 0普通用户，1会员,2管理员
	private Integer status = STATUS_ENABLE; //状态 0可用，1禁用

	/**
	 * @return true可用 false禁用
	 */
	@Transient
	public boolean isEnable() {
		return this.getStatus() != null && this.getStatus().intValue() == STATUS_ENABLE;
	}

	/**
	 * @return true管理员 false其他
	 */
	@Transient
	public boolean isAdmin() {
		return this.getRoleId() != null && this.getRoleId().intValue() == ROLEID_ADMIN;
	}

	/**
	 * @return true普通用户 false其他
	 */
	@Transient
	public boolean isUser() {
		return this.getRoleId() != null && this.getRoleId().intValue() == ROLEID_USER;
	}

	/**
	 * @return true会员用户 false其他
	 */
	@Transient
	public boolean isVIP() {
		return this.getRoleId() != null && this.getRoleId().intValue() == ROLEID_VIP;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	@Override
	public String toString() {
		return "UserEntity [loginName=" + loginName + ", username=" + username + ", mobile=" + mobile + ", password="
				+ password + ", mail=" + mail + ", qq=" + qq + ", roleId=" + roleId + ", status=" + status + "]";
	}

}
